package com.xfd.business.utils;

/**
 * @author junhong.xie
 * @since 2017年9月29日
 */
public class DateUtils {

	/**
	 * 格式化通话时长<br>
	 * 将传入的秒数格式化为 00:00:00 的形式
	 * @param seconds
	 * @return
	 */
	public static String forMatTimeDuration(int seconds) {

		String timeStr = "";
		int sec_hour = 3600;
		int sec_minute = 60;

		int t = seconds / sec_hour;
		timeStr += String.format("%02d", t);
		if (t > 0) {
			seconds = (seconds - (t * sec_hour));
		}

		t = seconds / sec_minute;
		timeStr += String.format(":%02d", t);
		if (t > 0) {
			seconds = (seconds - (t * sec_minute));
		}

		timeStr += String.format(":%02d", seconds);
		
		return timeStr;
	}
	
	public static void main(String[] args) {
		System.out.println(DateUtils.forMatTimeDuration(500));
		
	}
}
